import axios from '../config'
import http from 'axios'
import { PROJECT_API_URL } from '../baseURL'

export default {
  //获取所有用户
  getUserCompanys() {
    return axios({
      url: PROJECT_API_URL + '/user/img/get/all',
      method: "GET",
    })
  },
  getUserSections(iid) {
    return axios({
      url: PROJECT_API_URL + '/section/table/id/get/all/',
      method: "GET",
      params: { cid: iid }
    })
  },
  getUserPositions(sid) {
    return axios({
      url: PROJECT_API_URL + '/position/table/id/get/all/',
      method: "GET",
      params: { sid: sid }
    })
  },
  getUserGroups(pid) {
    return axios({
      url: PROJECT_API_URL + '/group/table/id/get/all/',
      method: "GET",
      params: { pid: pid }
    })
  },
  // getAccessToken(){
  //   return axios({
  //     url: PROJECT_API_URL + '/user/get/access/token',
  //     method: "GET",
  //     params:{}
  //   })
  // },
  getUserUserId(accessToken, code) {
    return axios({
      url: PROJECT_API_URL + '/user/get/userid',
      method: "GET",
      params: { code: code }
    })
  },
  // getUserBuildCode() {
  //   return axios({
  //     url: PROJECT_API_URL + '/user/build/code',
  //     method: "GET",
  //     params:{}
  //   })
  // },
  // getUserAuth() {
  //   return axios({
  //     url: PROJECT_API_URL + '/user/get/auth',
  //     method: "GET",
  //     params:{}
  //   })
  // },

  getOpenidInfo(openid) {
    return axios({
      url: PROJECT_API_URL + '/user/openid/get/info',
      method: "GET",
      params: { openid: openid }
    })
  },
  updateOrInsertInfo(data) {
    return axios({
      url: PROJECT_API_URL + '/user/transfer/insert/get/img/path',
      method: "POST",
      data: data
    })
  },

  uploadImg(url, formData) {
    console.log(formData.get('file'))
    return http.post(
      PROJECT_API_URL + url,
      formData,
      {
        headers: {
          "Content-Type": "multipart/form-data",
        },
      })
  },
}